<?php

//服务器和数据库信息
$servername = "localhost";
$username = "root";
$password = "";
$dbName = "mysql";
$tableName = "user";


//create connection
$conn = new mysqli($servername, $username, $password, $dbName);

//check connection 
if ($conn->connect_error) {
  die('fail to connect' . $conn->connect_error);
}

// echo('yes');
$Host = 'localhost';
$User = 'koga';
$Password = '123456';
$Select_priv = 'Y';
$Insert_priv = 'Y';
$Update_priv = 'Y';
$varname = ['Host','User','Password','Select_priv','Insert_priv','Update_priv'];
$data = "'" . implode("','",compact($varname))."'";
$varname = implode(",",$varname);

$sql = "INSERT INTO $tableName ($varname) VALUE ($data)";

if ($conn->query($sql) === true) {
  echo("create user -- $User success");
}
else {
  echo("fail to create user --$User".$conn->error);
}

